home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!sschaem
- From: sschaem@teleport.com (Stephan Schaem)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: PPC compilers
- Date: 7 Jan 1996 14:16:48 GMT
- Organization: Teleport - Portland's Public Access (503) 220-1016
- Message-ID: <4cokkg$415@maureen.teleport.com>
- References: <john.hendrikx.40ka@grafix.xs4all.nl> <MQAQx*XOe@yaps.rhein.de> <4bqhnf$6g5@sunsystem5.informatik.tu-muenchen.de> <jasonb.820051107@cs.uwa.edu.au> <4c9i2l$h3i@sunsystem5.informatik.tu-muenchen.de> <4ck47h$g07@maureen.teleport.com> <19960106.4EE928.CF59@sisyphus.demon.co.uk>
- NNTP-Posting-Host: julie.teleport.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Dave.Sparks@sisyphus.demon.co.uk wrote:
- : >>>>> "SS" == Stephan Schaem <sschaem@teleport.com> writes:
-
- : SS> I cant see how people can write code without knowing what data or
- : SS> type they manipulate...
-
- : Real-world programmers do it all the time. If you ever want to
-
- So you do math operation without knowing that your destination need to
- be a float or a 2 byte int?
-
- : join us, you'll have to learn to do it too. One of many examples
-
- Real world = commercial? I'm deep in it, thanks
-
- : is the ANSI C definition of the 'clock' function: the value
- : returned is of type 'clock_t', which is defined in a
- : system-dependent header file. SAS/C defines 'clock_t' to be an
- : unsigned 32-bit value, but other implementations can (and do)
- : define it to be signed or even 64-bit floating-point. Since the C
- : arithmetic operations (add, subtract, multiply, divide) are
- : overloaded (can be used on values of different types) the
- : programmer doesn't need to know what 'clock_t' is defined to be.
- : It isn't difficult to write ANSI C code which will compile and run
- : on different architectures: what is difficult is to convert C
- : which was written for one specific architecture, with no thought
- : given to portability.
-
- ANSI for good reason decided on a minimal size of all its basic type.
- This to help you the program choose the right type for your need.
-
- The only way you dont care is if you typedef all the ANSI type.
-
- So you created a structure to hold clock value with ulong? now recompile
- this on the system using a clock size of 64bit... where did the upper
- 32bit goes... you know have code that is broken.
-
- ex of something that wont break with a recompile:
-
- typedef short point2d
-
- struct RECTANGLE {
- point2d x1;
- point2d y1;
- point2d x2;
- point2d y2;
- } rectangle, *rectangle;
-
- then you declare you variable using rectangle, or point2d
-
- Then if later you find out in your design you need to use long (Or
- create another set of include for another platform), you
- can just chnage point2d... I rarely see that done... anyway
-
- It could be done in a macro assembler by 'tydefing' instruction size.
-
- typedef .w .point
-
- move.point (global_x1,a4),(rectangle+x1,a1)
-
- problem here... not all inst support all size :)
-
- The overall point here is. in C you need to know the type of x1 at
- declararion time, in asm at usage time. I guess in C you declare
- and forget? But this is not cool if you forget you are working with
- 2 byte ints...
-
- about loop counter size... should I use ulong and forget about it,
- or use ushort to be sure of optimal speed on my target CPU and remember
- my declaration type in case I want to use it for a loop count bigger then
- 65535?. (this result in a sub/bcc vs dbcc encoding on 680x0... )
-
-
- : Incidentally, your References: header was broken (truncated in the
- : middle of a reference). You need to write yourself a new newsreader.
-
- I'm using tin :(
-
- Stephan
-